var Fans = {};

//将数据库字段转换成实体类
Fans.dbConvertModel = function(db){
  var fans = {};
  if(!db) return fans;
  if(db.fans_id) fans.id = db.fans_id;
  if(db.account_id) fans.accountId = db.account_id;
  if(db.fans_subscribe) fans.subscribe = db.fans_subscribe;
  if(db.fans_openid) fans.openId = db.fans_openid;
  if(db.fans_nickname) fans.nickname = db.fans_nickname;
  if(db.fans_sex) fans.sex = db.fans_sex;
  if(db.fans_city) fans.city = db.fans_city;
  if(db.fans_country) fans.country = db.fans_country;
  if(db.fans_province) fans.province = db.fans_province;
  if(db.fans_language) fans.language = db.fans_language;
  if(db.fans_headimgurl) fans.headImgUrl = db.fans_headimgurl;
  if(db.fans_updatetime) fans.updateTime = db.fans_updatetime;
  if(db.fans_phonenumber) fans.phoneNumber = db.fans_phonenumber; 
  if(db.fans_subscribe_time) fans.subsribeTime = db.fans_subscribe_time;
  if(db.fans_createtime) fans.createTime = db.fans_createtime;
  if(db.fans_authorize) fans.authorize = db.fans_authorize;
  //if(db.union_id) fans.unionId = db.union_id;
  
  return fans;
};

//实体转换成数据库字段
Fans.modelConvertDb = function(obj){
  var db = {};
  if(!obj) return db;
  if(obj.id) db.fans_id = obj.id;
  if(obj.accountId) db.account_id = obj.accountId;
  if(obj.subscribe) db.fans_subscribe = obj.subscribe;
  if(obj.openId) db.fans_openid = obj.openId;
  if(obj.nickname) db.fans_nickname = obj.nickname;
  if(obj.sex) db.fans_sex = obj.sex;
  if(obj.city) db.fans_city = obj.city;
  if(obj.country) db.fans_country = obj.country;
  if(obj.province) db.fans_province = obj.province;
  if(obj.language) db.fans_language = obj.language;
  if(obj.headImgUrl) db.fans_headimgurl = obj.headImgUrl;
  if(obj.updateTime) db.fans_updatetime = obj.updateTime;
  if(obj.phoneNumber) db.fans_phonenumber = obj.phoneNumber; 
  if(obj.subsribeTime) db.fans_subscribe_time = obj.subsribeTime;
  if(obj.createTime) db.fans_createtime = obj.createTime;
  if(obj.authorize) db.fans_authorize = obj.authorize;
  
  return db;
};

//将微信信息转化成实体信息
Fans.wechatConvertModel = function(obj){
  var fans = {};
  if(!obj) return fans;
  if(obj.subscribe) fans.subscribe = obj.subscribe;
  if(obj.openid) fans.openId = obj.openid;
  if(obj.nickname) fans.nickname = obj.nickname;
  if(obj.sex) fans.sex = obj.sex;
  if(obj.city) fans.city = obj.city;
  if(obj.country) fans.country = obj.country;
  if(obj.province) fans.province = obj.province;
  if(obj.headimgurl) fans.headImgUrl = obj.headimgurl;
  if(obj.language) fans.language = obj.language;
  if(obj.subscribe_time) fans.subscribeTime = obj.subscribe_time;
  if(obj.unionid) fans.unionId = obj.unionid;
  return fans;
};



    /**
     * 将微信信息转化成实体信息
     */
    /*fans.getModelFromWechat = function(json) {
      var fans = {};
      if(!json) return fans;
      if(json.subscribe) fans.subscribe = json.subscribe;
      if(json.openid) fans.openId = json.openid;
      if(json.nickname) fans.nickname = json.nickname;
      if(json.sex) fans.sex = json.sex;
      if(json.city) fans.city = json.city;
      if(json.country) fans.country = json.country;
      if(json.province) fans.province = json.province;
      if(json.headimgurl) fans.headImgUrl = json.headimgurl;
      if(json.language) fans.language = json.language;
      if(json.subscribe_time) fans.subscribeTime = json.subscribe_time;
      if(json.unionid) fans.unionId = json.unionid;
 };*/


module.exports = Fans;